package com.biyabi;


import com.biyabi.dao.ProductMapper;
import com.biyabi.entity.Product;
import com.biyabi.service.CollectionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest
public class collection {
    @Resource
    private CollectionService collectionService;
    @Resource
    private ProductMapper productMapper;
    @Test
    public void add(){
        //模拟一个商品对象
        Product product = productMapper.selectByPrimaryKey("42e39323-3ee4-43ef-b20c-4281b779ff11");
        collectionService.add("1",product);
    }
    @Test
    public void selectAll(){
        Map<String, Product> colMap = collectionService.selectAllMy("1");
        for (String s : colMap.keySet()) {
            Product product = colMap.get(s);
            System.out.println(product.getName());
        }
    }

    @Test
    public void del(){
        collectionService.delete("1","42e39323-3ee4-43ef-b20c-4281b779ff11");
    }
}
